import React, { Component } from "react";

class Hello extends Component {
  render() {
    console.log("Hello props", this.props);
    return (
      <div className="hello">
        <h1>Hello</h1>
        <input type="text" ref={this.props.forwardRef} />
      </div>
    );
  }
}

const NewHello = React.forwardRef((props, ref) => {
  console.log("NewHello props: ", props); // {a: 1, b: 2}
  console.log("NewHello ref: ", ref);
  // 返回一段jsx
  return <Hello {...props} forwardRef={ref} />;
});

export default NewHello;
